<@ms.html5>
     <@ms.nav title="商品属性增加" back=true>
        <@ms.saveButton  onclick="save()"/>
    </@ms.nav>
    <@ms.panel>
        <@ms.form name="articleForm" isvalidation=true>
            <@ms.hidden name="bpId" value="${baseProperty.bpId?default(0)}"/>
            <@ms.text name="propertyName" colSm="2" width="200" label="属性名称"    title="属性名称" size="5"  placeholder="请输入属性名称"  value="${baseProperty.propertyName?default('')}"  validation={"maxlength":"20","required":"true", "data-bv-notempty-message":"属性名称不能为空","data-bv-stringlength-message":"属性名称在20个字符以内!"}/>
        	<@ms.text name="sort"  colSm="2" width="200" label="自定义顺序" title="自定义顺序" size="5"  placeholder="请输入属性顺序" value="${baseProperty.sort?default(0)}" validation={"data-bv-between":"true","data-bv-between-message":"自定义顺序必须大于0","data-bv-between-min":"0", "data-bv-between-max":"99999999","data-bv-notempty-message":"自定义顺序不能为空"}/>
        </@ms.form>
    </@ms.panel>
</@ms.html5>
<script>
    var url = "${managerPath}/goods/baseProperty/save.do";
    if($("input[name = 'bpId']").val() > 0){
        url = "${managerPath}/goods/baseProperty/update.do";
        $(".btn-success").text("更新");
    }
    //编辑按钮onclick
    function save() {
        $("#articleForm").data("bootstrapValidator").validate();
            var isValid = $("#articleForm").data("bootstrapValidator").isValid();
            if(!isValid) {
                <@ms.notify msg= "数据提交失败，请检查数据格式！" type= "warning" />
                return;
        }
        var btnWord =$(".btn-success").text();
        $(".btn-success").text(btnWord+"中...");
        $(".btn-success").prop("disabled",true);
        $.ajax({
            type:"post",
            dataType:"json",
            data:$("form[name = 'articleForm']").serialize(),
            url:url,
            success: function(status) {
                if(status.result == true) { 
                    <@ms.notify msg="保存或更新成功" type= "success" />
                    location.href = "${managerPath}/goods/baseProperty/index.do";
                }
                else{
                    <@ms.notify msg= "保存或更新失败！" type= "fail" />
                    location.href= "${managerPath}/goods/baseProperty/index.do";
                }
            }
        })
    }    
</script>